Skip to main content

All Questions

2votes
2answers
112views

Print Binary coded decimal Numbering of a given input number

Example 1 input:3 output:0011 Example 2 input : 15 output: 1111 in the below example code 15 is input. I have taken 8 4 2 1 as array for Binary coded decimal numbering this code is working as ...
Ramakrishna's user avatar
3votes
3answers
1kviews

Printing rotations of an array 7 times

Loop through a given array 7 times and print the following output: int[] arr = { 9, 2, 7, 4, 6, 1, 3 }; ...
Ramakrishna's user avatar
2votes
1answer
2kviews

Rotate matrix 90 degrees

I recently did problem 1.7 Rotate Matrix in Cracking the Coding Interview. I realized my code is very different than what is in the book and also from what I'm finding online (I'm having trouble ...
stillearning's user avatar
6votes
3answers
15kviews

Finding common elements in two arrays

I just had this question in an interview. I had to write some code to find all the common elements in two arrays. This is the code I wrote. I could only think of a 2-loop solution, but something ...
Frank's user avatar
5votes
3answers
126views

Array's reverse vs simple arithmethic

I was asked to print numbers from 100 to 1 in a for loop with the index starting from 1. I came up with this solution: ...
Alish Dhamala's user avatar
2votes
1answer
3kviews

Count the number of times a particular number appears in a sorted array of integers

I had an interview question awhile back that went more or less as follows: You have a sorted array of integers representing the ages of every person living on earth. There's a single entry in the ...
EJoshuaS - Stand with Ukraine's user avatar
2votes
1answer
1kviews

Find the contiguous subarray within an array (containing at least one number) which has the largest sum

Interview Q: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example: Given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [...
Smart Home's user avatar
2votes
3answers
469views

Minimum element in a sorted rotated array

A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, ...
Software Engineer's user avatar
17votes
5answers
4kviews

Given a sequence of positive integers A and an integer T, return true if a continuous sequence of A sums up to exactly T

Here is the source of the question, and my solution is below. Did I determine the worst case correctly? If you find any input where it doesn't work, please let me know. ...
Maksim Dmitriev's user avatar
7votes
2answers
1kviews

Finding pairs of numbers within A that add up to N

I am working on an interview question from Amazon Software Interview: Given an integer N and an array of unsorted integers A find all pairs of numbers within A which add up to N I have a working ...
committedandroider's user avatar
4votes
3answers
2kviews

Removing duplicates from an array

I recently wrote this JavaScript algorithm for removing duplicates from an array as part of a job interview process, but was turned down for the position after submitting the code. I didn't receive ...
jmknoll's user avatar
7votes
3answers
11kviews

Find elements occurring even number of times in an integer array

I came across an interview question, which is like this: You have an array of integers, such that each integer is present an odd number of time, except 3 of them. Find the three numbers. I tried ...
Rohit Jain's user avatar

close